<?php
include_once(__DIR__.'/../includes/utilidades.php');
require_once(__DIR__.'/../includes/seguridad.php');
require_once(__DIR__.'/../includes/html.php');
session_start();

if (!rolOK($_SESSION['roles'],array('admin')))
        exit;

//print_r($_SESSION);
$temporadaid = $_SESSION['estado']['temporada'][0]['id'];
$competicionid=$_REQUEST['id'];
$temporada = select("select * from temporada", "id=" . $temporadaid);
$competicion =  select("select * from competicion", "id=" . $competicionid);
//print_r($competicion);
print "<h1> Temporada: " . $temporada[0]['nombre'] ."</h1>";
print "<h2> Competicion: " . $competicion[0]['nombre'] ."</h2>";
$sql = "select j.id as id, j.nombre as Nombre, j.fecha as Fecha, c.nombre as Organizador,j.localidad as Localidad" .
        " from jornada j left join club c on j.idorganizador=c.id where idcompeticion=" .$competicionid.
        " order by Fecha asc"; 
//$jornada = select("select * from jornada","idcompeticion=" . $competicionid);
$jornada = select2($sql);
$actual = $_SERVER['REQUEST_SCHEME'] . "://" . $_SERVER['SERVER_NAME'] . $_SERVER['PHP_SELF'] . "?" . $_SERVER['QUERY_STRING'];
actualizarEstado($_SESSION,$competicion,'competicion',$tablas);
//print ($actual);
 
 
 $_SESSION['afterAdd']['jornada'] = $actual;
 $_SESSION['afterDel']['jornada'] = $actual;
 //$_SESSION['competicion']['id']=$competicionid;
 
 $valoresFK = array ('idcompeticion' => $competicionid );
 
 $j= new HTML_Tabla($jornada);
 $j->setDisplayColumnNames(array('Nombre'=>'Jornada','Fecha'=>'Fecha','Organizador'=>'Organizador','Localidad'=>'Localidad'));
 $j->setEnlaces('id', array('Acceder'=>'verjornada.php','Modificar'=>'../comun/editObjetoForm.php?nombreObjeto=jornada'));
 $j->toHTML();
 $j->printHTML();
 
 //toHTML('jornada',$jornada,'id');
 //HTMLadd("jornada",$valoresFK);
 $jornada[0]['idcompeticion']=$competicionid;

 
 if ((isUserInRol($_SESSION['username'], "admin"))) {
     HTMLadd2($jornada,'jornada',$tablas);
 }
 
/* 
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

